﻿package tests;
import fpc.controls.buttons.CheckBox;
import fpc.controls.buttons.Button;
import fpc.containers.Panel;
import fpc.controls.buttons.RadioButton;
import fpc.controls.buttons.RadioButtonGroup;
import fpc.layouts.ILineLayout;
import fpc.layouts.VLayout;
import fpc.styles.Style;
import glam.skins.GlamCheckBox;
import glam.skins.GlamRadioButton;

enum RadioButtonValue
{
	VALUE0;
	VALUE1;
	VALUE2;
	VALUE3;
}

class RadioButtonTest extends GenericTest
{
	public function new() 
	{
		super();
	}
	
	override function init()
	{
		var layout = new VLayout();
		var panel = new Panel<ILineLayout>(layout);
		panel.addTo(this);
		
		panel.style = new Style()
			.setSkin(RadioButton.SKIN_TYPE_RADIO_BUTTON, new GlamRadioButton())
			.setSkin(CheckBox.SKIN_TYPE_CHECK_BOX, new GlamCheckBox());
		
		var group = new RadioButtonGroup<RadioButtonValue>(onChange);
		
		var radioButton = new RadioButton('Radio button 0');
		radioButton.enabled = false;
		layout.add(radioButton);
		group.addButton(radioButton, RadioButtonValue.VALUE0);
		
		var radioButton = new RadioButton('Radio button 1');
		layout.add(radioButton);
		group.addButton(radioButton, RadioButtonValue.VALUE1);
		
		var radioButton = new RadioButton('Radio button 2');
		layout.add(radioButton);
		group.addButton(radioButton, RadioButtonValue.VALUE2);
		
		var radioButton = new RadioButton('Radio button 3');
		layout.add(radioButton);
		group.addButton(radioButton, RadioButtonValue.VALUE3);
		
		group.value = RadioButtonValue.VALUE0;
		
		var checkBox = new CheckBox('Check box');
		checkBox.selected = true;
		checkBox.enabled = false;
		layout.add(checkBox);
		
		var button = new Button('Button');
		layout.add(button);
	}
	
	function onChange(value:RadioButtonValue)
	{
		trace(value);
	}
}